/**
 * 
 */
package com.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.demo.bean.City;
import com.demo.bean.Info;
import com.demo.common.Constants;
import com.demo.dao.CityDataDAO;
import com.demo.service.CityDataService;
import com.demo.util.PageUtil;

/**
 * @author Issac
 *
 */
@Controller
@RequestMapping("/data")
public class CityDataController {

	@Autowired
	private CityDataService cityDataService;
	
	public CityDataService getCityDataService() {
		return cityDataService;
	}

	public void setCityDataService(CityDataService cityDataService) {
		this.cityDataService = cityDataService;
	}

	@RequestMapping(value="/add", method = RequestMethod.POST)
	public ModelAndView list(Info info){
		int result = cityDataService.addCityData(info);
		if (Constants.SUCCESS_ACTION == result){
			return new ModelAndView("myDataList");
		}
		else {
			return new ModelAndView("error");
		}
	}
	
	@RequestMapping(value="/searchindex", method = RequestMethod.POST)
	public ModelAndView searchindex(String searchType, String searchPosition, int pageSize, int currentPage){
		
		PageUtil data = null;
		if (Constants.NEWS_TYPE.equals(searchType)){
			
		}
		else{
			data = cityDataService.searchIndex(searchType, searchPosition, currentPage, pageSize);
		}
		return new ModelAndView("dataList", "data", data);
		
	}
}
